#include<bits/stdc++.h>
using namespace std;
int cha,modl,modr,n,l,r,ans;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	cha=r-l+1;
	if(cha>=n)
		ans=n-1;
	else{
		modl=l%n;
		modr=r%n;
		if(modl>modr)
			ans=n-1;
		else
			ans=modr;
	}
	cout<<ans<<endl;
	return 0;
}
